package com.weixin.paleituo.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.weixin.paleituo.R;
import com.weixin.paleituo.base.BaseRecycleAdapter;
import com.weixin.paleituo.bean.Brands;
import com.weixin.paleituo.help.RecycleViewHolder;
import com.weixin.paleituo.help.RecycleViewOnItemOnclickListener;
import com.weixin.paleituo.util.UIUtils;

import java.util.List;

/**
 * Author yichao
 * Time  2018/3/20 14:01
 * Dest  选择品牌
 */

public class BrandSelectRecycleAdapter extends BaseRecycleAdapter<Brands> {
    private List<Integer> mIntegerList;
    private TextView mTvName;
    private ImageView mImageViewLine;
    private View mLine;

    public BrandSelectRecycleAdapter(Context context, List<Brands> datas) {
        super(context, datas, R.layout.item_recyclevie_brandselect);
    }
    @Override
    protected void setData(final RecycleViewHolder holder, Brands brands, final int position) {
        mTvName = holder.getItemView(R.id.tv_name_item_recyclevie_brandselect);
        mImageViewLine = holder.getItemView(R.id.iv_item_recyclevie_brandselect);
        mLine = holder.getItemView(R.id.viewline_item_recyclevie_brandselect);

     if (mIntegerList.contains(brands.getBrandId())){
         mTvName.setTextColor(UIUtils.getColor(R.color.c_29CE7E));
         mImageViewLine.setVisibility(View.VISIBLE);
         mLine.setVisibility(View.VISIBLE);
     }else {
         mTvName.setTextColor(UIUtils.getColor(R.color.c_ff383838));
         mImageViewLine.setVisibility(View.INVISIBLE);
         mLine.setVisibility(View.INVISIBLE);
     }
        mTvName.setText(brands.getBrand()+"");
     holder.mItemView.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
             if (mRecycleViewOnItemOnclickListener!=null){
                 mRecycleViewOnItemOnclickListener.onItemClick(v,holder,position);
             }
         }
     });

    }

    /**
     * 选中的id
     * @param integerList
     */
    public void setSelect(List<Integer> integerList) {
        mIntegerList = integerList;
    }

    private RecycleViewOnItemOnclickListener mRecycleViewOnItemOnclickListener;

    public void setRecycleViewOnItemOnclickListener(RecycleViewOnItemOnclickListener recycleViewOnItemOnclickListener){

        mRecycleViewOnItemOnclickListener=recycleViewOnItemOnclickListener;
    }

}
